package com.ruoyi.exam.domain;

import lombok.Data;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Data
public class Category {
    private int category;
    private String name;

    private List<Subject> subjects;

    public Map<String ,Object> toMap(){
        Map<String ,Object> map = new HashMap<>();
        map.put("category", category);
        map.put("name", name);

        map.put("subjects" ,subjects.stream().collect(Collectors.toMap(Subject::getId ,subject -> subject)));
        return map;
    }
}
